---
layout: "default"
title: "EnumerateSequence"
description: "Swift documentation for 'EnumerateSequence': The SequenceType returned by enumerate().  EnumerateSequence."
keywords: "EnumerateSequence,struct,swift,documentation,generate,Generator,Element"
root: "/v1.2"
---

<div class="intro-declaration"><code class="language-swift">struct EnumerateSequence&lt;Base : SequenceType&gt;</code></div>

<div class="discussion comment">
    <p>The <code>SequenceType</code> returned by <code>enumerate()</code>.  <code>EnumerateSequence</code>
is a sequence of pairs (<em>n</em>, <em>x</em>), where <em>n</em>s are consecutive
<code>Int</code>s starting at zero, and <em>x</em>s are the elements of a <code>Base</code>
<code>SequenceType</code>:</p>

<pre><code class="language-swift">var s = EnumerateSequence([&quot;foo&quot;, &quot;bar&quot;])
Array(s) // [(0, &quot;foo&quot;), (1, &quot;bar&quot;)]</code></pre>

<p>Note:: idiomatic usage is to call <code>enumerate</code> instead of
constructing an <code>EnumerateSequence</code> directly.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">SequenceType, _SequenceType, _Sequence_Type</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">Generator = EnumerateGenerator&lt;Base.Generator&gt;</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
<div class="declaration">
<code class="language-swift">Element = Generator.Element</code>
<div class="comment">
    <p><em>Type alias inferred.</em></p>
</div>
</div>
</td>
</tr>


<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_">init(<wbr>_:)</a><div class="comment collapse" id="comment-init_"><div class="p">
    <p>Construct from a <code>Base</code> sequence</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ base: Base)</code>

    </div></div>
</div>





<h3>Instance Methods</h3>
<div class="declaration" id="func-generate">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-generate">func generate()</a>
        
<div class="comment collapse" id="comment-func-generate"><div class="p">
    <p>Return a <em>generator</em> over the elements of this <em>sequence</em>.</p>

<p>Complexity: O(1)</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func generate() -&gt; EnumerateGenerator&lt;Base.Generator&gt;</code>
    
    
</div></div>
</div>


